program IPtest;
uses
  Classes, SysUtils;
Type vector = Array [1..255] of string; //Declaratia Vectorului ce pastreaza IP-urile
Var v:vector;
    getmyip,newip,oldip,ip:string;
    i,c,ls_vector:integer;

Function afla_lungimea_vectorului(v:vector):integer;
begin
result:=0;
for i:=0 to 255 do if v[i]<>'' then result:=result+1;
end;

Procedure adauga_ip_in_vector(ip:string;i:integer);
Begin
for c:= ls_vector+1 downto i do v[c]:=v[c-1];
v[i]:=ip;
end;

Procedure sorteaza_vector(ip:string);
Begin
ls_vector:=afla_lungimea_vectorului(v);
i:=0;
repeat
if ip>v[i] then begin
                i:=i+1;
                end
           else begin
                adauga_ip_in_vector(ip,i);
                break;
                end;
until i=ls_vector;
if ip>v[afla_lungimea_vectorului(v)] then v[i+1]:=ip;
end;

Begin
getmyip:='127.0.0.50';
newip:='85.204.211.66';

v[0]:='127.0.0.1';
v[1]:='127.0.0.99';
v[2]:='127.0.1.99';

if getmyip<>newip then begin
                       oldip:=newip;
                       newip:=getmyip;
                       end;
sorteaza_vector(getmyip);
for i:=0 to afla_lungimea_vectorului(v) do writeln(v[i]);
readln;
end.
